package app

import "kubeInstall/utils"

const IngressForAppManifests = `
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: grafana
  namespace: monitoring-system 
spec:
  rules:
  - host: grafana.{{.ClusterName}}.{{.DomainName}}.com
    http:
      paths:
      - backend:
          serviceName: grafana
          servicePort: 3000
        path: /
  - host: prometheus.{{.ClusterName}}.{{.DomainName}}.com
    http:
      paths:
      - backend:
          serviceName: prometheus
          servicePort: 9090
        path: /
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: kibana
  namespace: logging-system
spec:
  rules:
  - host: kibana.{{.ClusterName}}.{{.DomainName}}.com
    http:
      paths:
      - backend:
          serviceName: kibana-logging
          servicePort: 5601
        path: /
`

type IngressForAPP struct {
	DomainName  string `json:"domain_name"`
	ClusterName string `json:"cluster_name"`
}

func (ing *IngressForAPP) ToYaml() string {
	return utils.Render(IngressForAppManifests, ing)
}
func (ing *IngressForAPP) GetAppName() string {
	return "app_ingress"
}
